import React from 'react';
import RCTable from '@components/table/index.jsx';

import Request from '@service/ajax.js';
import Tools from '@untils/tools.jsx';
import {OPINON} from '@apis/index.js';

import './scss/opinon.scss';

const _req = new Request();

class OpinonAnalys extends React.Component {

    constructor(props) {
        super(props);
        this.state = {};
        this.setCallback = Tools.setCallback.bind(this);
    }

    componentDidMount() {
        this.requestList(10, 1, '');
    }

    requestList(pageSize, currentPage, name) {
        let data = {pageSize, currentPage, name};
        let options = Tools.objectAssign(OPINON.ANALYSIS, {data});
        _req.ajaxList(options, this);
    }

    render() {
        let {pagination = null, list = [], /*selectedRowKeys = []*/} = this.state;
        const columns = [{
            title: '序号',
            key: '序号',
            render: (txt, row, index) => <span>{index + 1}</span>
        }, {
            title: '音频名称',
            dataIndex: 'name',
            key: 'name',
            render: (txt) => <p className="ell-1" title={txt || ''}>{txt || '---'}</p>
        }, {
            title: '数据来源',
            dataIndex: 'sourceName',
            key: 'sourceName',
            render: (txt) => <span>{txt || '---'}</span>
        }, {
            title: '舆情方向',
            dataIndex: 'tag',
            key: 'tag',
            render: (txt) => <span>{txt || '---'}</span>
        }, {
            title: '是否禁忌',
            dataIndex: 'taboo',
            key: 'taboo',
            render: (txt) => <span>{(txt && '是') || '否'}</span>
        }, {
            title: '操作',
            render: () => <span className="option-item">查看详情</span>
        }];
        return (
            <div className="opinon-analys">
                <div className="rc-table-content">
                    <RCTable
                        columns={columns}
                        dataSource={list}
                        // selectType="radio"
                        // updateSelected={this.setCallback}
                        // selectedRowKeys={selectedRowKeys}
                        pagination={pagination}
                        onChange={(pagination) => {
                            let {current, pageSize, name = ''} = pagination;
                            this.requestList(pageSize, current, name);
                        }}
                    />
                </div>
            </div>
        )
    }
}

export default OpinonAnalys;